<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"
    import="java.io.PrintWriter,
    cn.edu.nju.software.model.administrator.DisplayManager,
    cn.edu.nju.software.model.administrator.MemberManager" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%
	String administratorName = (String) application.getAttribute("administratorName");
	if (administratorName == null || administratorName.equals("")) {
		PrintWriter printWriter = response.getWriter();
		printWriter.println("<script>alert('Please login first!');" + 
							"window.location.href='index.jsp';</script>");
	}
%>

<html>

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
	<link type="text/css" rel="stylesheet" href="../css/administrator/ticket.css" />
	<link type="text/css" rel="stylesheet" href="../css/administrator/menu.css" />
	<link type="text/css" rel="stylesheet" href="../css/administrator/footer.css" />
	<title>售票</title>
</head>

<body>
	<div id="menu">
		<a href="administrator.jsp"><img src="../images/administrator/menu/menu_homepage.png" alt="首页" /></a>
		<a href="member.jsp"><img src="../images/administrator/menu/menu_member.png" alt="会员管理" /></a>
		<a href="display.jsp"><img src="../images/administrator/menu/menu_display.png" alt="放映管理" /></a>
		<a href="ticket.jsp"><img src="../images/administrator/menu/menu_ticket.png" alt="售票" /></a>
		<a href="statistics.jsp"><img src="../images/administrator/menu/menu_statistics.png" alt="统计分析" /></a>
		<a href="information.jsp"><img src="../images/administrator/menu/menu_information.png" alt="信息" /></a>
		<a href="index.jsp"><img src="../images/administrator/menu/menu_logout.png" alt="注销" /></a>
	</div>
	
	<div id="content">
		
		<div id="ticket_name">
			<div class="cell_title">会员购票</div>
			<form method="post" action="../BookingAtScene.do">
				<table>
					<tr class="color_row">
						<th>放映室</th>
						<td>
							<select name="hall">
								<%
								DisplayManager displayManager = new DisplayManager();
								String[] halls = displayManager.fetchAllHalls();
								for (int i = 0; i < halls.length; i++) {
									String hall = halls[i];
									%>
									<option value=<%= hall %>><%= hall %></option>
									<%
								}
								%>
							</select>
						</td>
					</tr>
					<tr>
						<th>影片</th>
						<td>
							<select name="movie">
								<%
								String[] movies = displayManager.fetchAllMovies();
								for (int i = 0; i < movies.length; i++) {
									String movie = movies[i];
									%>
									<option value<%= movie %>><%= movie %></option>
									<%
								}
								%>
							</select>
						</td>
					</tr>
					<tr class="color_row">
						<th>用户</th>
						<td>
							<select name="username">
								<%
								MemberManager memberManager = new MemberManager();
								String[] members = memberManager.fetchAllMembers();
								for (int i = 0; i < members.length; i++) {
									String member = members[i];
									%>
									<option value=<%= member %>><%= member %></option>
									<%
								}
								%>
							</select>
						</td>
					</tr>
					<tr>
						<th>票数</th>
						<td><input type="text" name="count" value="1" /></td>
					</tr>
					<tr class="color_row">
						<th></th>
						<td>
							<input type="submit" value="订票" />
							<input type="reset" value="重新定制" />
						</td>
					</tr>
				</table>
			</form>
		</div>
		
		<div id="ticket_anonymous">
			<div class="cell_title">一般购票</div>
			<form method="post" action="../BookingAtScene.do">
				<table>
					<tr class="color_row">
						<th>放映室</th>
						<td>
							<select name="hall">
								<%
								for (int i = 0; i < halls.length; i++) {
									String hall = halls[i];
									%>
									<option value=<%= hall %>><%= hall %></option>
									<%
								}
								%>
							</select>
						</td>
					</tr>
					<tr>
						<th>影片</th>
						<td>
							<select name="movie">
								<%
								for (int i = 0; i < movies.length; i++) {
									String movie = movies[i];
									%>
									<option value<%= movie %>><%= movie %></option>
									<%
								}
								%>
							</select>
						</td>
					</tr>
					<tr class="color_row">
						<th>票数</th>
						<td><input type="text" name="count" value="1" /></td>
					</tr>
					<tr>
						<th></th>
						<td>
							<input type="submit" value="订票" />
							<input type="reset" value="重新定制" />
						</td>
					</tr>
				</table>
			</form>
		</div>
		
	</div>
	
	<div id="footer">
		<p>
			Copyright &copy; <a href="mailto:zyy08@software.nju.edu.cn">张迎亚</a>·南京大学·软件学院·2011春节
		</p>
	</div>
	
</body>

</html>